
package com.primeton.eos.oss.model.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eos.system.utility.PageResultList;

import com.eos.data.datacontext.DataContextManager;
import com.eos.data.datacontext.IMUODataContext;

import com.primeton.eos.oss.model.dao.MdmCrecAccountDao;
import com.primeton.eos.oss.model.newdataset.MdmCrecAccount;

@Service
public class MdmCrecAccountService {

    @Autowired
    private MdmCrecAccountDao mdmCrecAccountDao;


    public PageResultList<MdmCrecAccount> queryMdmCrecAccountsWithPage(String username,  int pageSize, int pageIndex) {
        //TODO 记录日志
        return mdmCrecAccountDao.queryMdmCrecAccountsWithPage(username,  pageSize, pageIndex);
    }

    public MdmCrecAccount getMdmCrecAccountById(String id) {
        //TODO 记录日志
        return mdmCrecAccountDao.getEntity(MdmCrecAccount.QNAME, id);
    }

    @Transactional
    public void createMdmCrecAccount(MdmCrecAccount mdmCrecAccount) {
        //TODO 记录日志
    	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        mdmCrecAccount.set("createUser", userName);
        mdmCrecAccount.set("createTime", new Date());
        mdmCrecAccount.set("updateUser", userName);
        mdmCrecAccount.set("updateTime", new Date());

        mdmCrecAccountDao.getPrimaryKey(mdmCrecAccount);
        mdmCrecAccountDao.insertEntity(mdmCrecAccount);
    }
    
    @Transactional
    public void modifyMdmCrecAccount(MdmCrecAccount mdmCrecAccount) {
        //TODO 记录日志
     	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        mdmCrecAccount.set("updateUser", userName);
        mdmCrecAccount.set("updateTime", new Date());
 
        mdmCrecAccountDao.updateEntity(mdmCrecAccount);
    }
    
     @Transactional
    public void removeMdmCrecAccount(MdmCrecAccount[] mdmCrecAccount) {
        //TODO 记录日志
        mdmCrecAccountDao.deleteEntity(mdmCrecAccount);
    }

}





